package org.example.ch03;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;


/**
 * @author yang
 * @date 2024-03-19
 */
public class TestMain {
    public static void main(String[] args) throws Exception{


        GetSum gs1 = new GetSum(1,100);
        GetSum gs2 = new GetSum(101,900);
        GetSum gs3 = new GetSum(901,1000);

        ExecutorService executorService = Executors.newFixedThreadPool(10);

        Future<Integer> ft01 =  executorService.submit(gs1);
        Future<Integer> ft02 = executorService.submit(gs2);
        Future<Integer> ft03 =  executorService.submit(gs3);

        Integer sum = ft01.get() + ft02.get() + ft03.get();
        System.out.println(sum);

        executorService.shutdown();
    }
}
